<?php

/*
	info: AJAX操作
	date: 2011-12-19
*/

define('PAGESCRIPT', 'ajax');
define('AJAX_MODE', TRUE);
define('USER_LOGIN_CHECK', TRUE);
require dirname(__FILE__).'/include/common.inc.php';

$webglobal['file_ajax'] = array();
$webglobal['file_ajax']['error'] = array('state'=>0,'info'=>'非法请求');
$webglobal['file_ajax']['response'] = array();

@header("Expires: -1");
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
header("Content-Type: application/json; charset=".$webconfig['webcharset']);

//用户信息
if ($webglobal['action']=='userinfo')
{
	$tempuser = $user;
	if (isset($tempuser['pwd']))
	{
		unset($tempuser['pwd']);
	}
	echo json_encode($tempuser);
	exit();
} elseif ($webglobal['action']=='category') {
	$tempReturn = array();
	$webrequest['type'] = isset($webrequest['type']) ? intval($webrequest['type']) : 0;
	if ($webrequest['type'] == 1) {
		$tempReturn = $couponCategoryDataModel->formatClassToJson(0, 2);
	} elseif ($webrequest['type'] == 2) {
		$tempReturn = $companyCategoryDataModel->formatClassToJson(0, 2);
	} else {
		$tempReturn = json_encode($tempReturn);
	}
	echo $tempReturn;
	exit;
} else {
	ajax_ShowError();
}

function ajax_ShowError()
{
	global $webglobal;
	echo json_encode($webglobal['file_ajax']['error']);
	exit();
}
